package com.rem.chat.service.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author: Themberfue
 * @date: 2025/6/15 15:53
 * @description:
 */
@AllArgsConstructor
@Getter
public enum MessageTypeEnum {
    INIT(0, "", "连接WS获取消息"),
    ADD_FRIEND(1, "", "添加好友打招呼消息"),
    CHAT(2, "", "普通聊天信息"),
    GROUP_CREATE(3, "群组已经创建好，可以和好友一起畅聊了", "群创建成功"),
    CONTACT_APPLY(4, "", "好友申请"),
    MEDIA_CHAT(5, "", "媒体文件"),
    FILE_UPLOAD(6, "", "文件上传完成"),
    FORCE_OFF_LINE(7, "", "强制下线"),
    DISSOLUTION_GROUP(8, "群聊已解散", "解散群聊"),
    ADD_GROUP(9, "%s加入了群组", "加入群聊"),
    CONTACT_NAME_UPDATE(10, "", "更新昵称"),
    LEAVE_GROUP(11, "%s退出了群聊", "退出群聊"),
    REMOVE_GROUP(12, "%s被管理员移除了群聊", "被管理员移除了群聊"),
    ADD_FRIEND_SELF(13, "", "添加好友打招呼消息");

    private final Integer type;
    private final String initMessage;
    private final String desc;

    public static MessageTypeEnum getByStatus(Integer type) {
        try {
            for (MessageTypeEnum item: MessageTypeEnum.values()) {
                if (type.equals(item.getType())) {
                    return item;
                }
            }
            return null;
        } catch (Exception e) {
            return null;
        }
    }
}
